textArea.with{
    def selection = selection[0].clone()
    def up = 0
    selectedText = selectedText.replaceAll(/[A-Z]/){
        up++
        ("_" + it.toLowerCase())
    }.replaceAll(/^_/, "")
    addToSelection(new org.gjt.sp.jedit.textarea.Selection.Range(selection.start, selection.end + up))
}
